<?php $this->beginBlock('title');?>
    文章列表
<?php $this->endBlock();?>
<?php $this->params['breadcrumbs'] =
    [
        [
            'label' => '文章列表',
//            'url' => \yii\helpers\Url::to(['admin/category/add']),
            'class' => 'active',
        ]
    ];
?>


<div class="row">
    <div class="col-sm-12 col-md-12">
        <div class="block-flat">
            <div class="header">
                <h5>文章列表</h5>
            </div>
            <div class="content">
                <table class="no-border">
                    <thead class="no-border">
                    <tr>
                        <th style="width: 5%">序号</th>
                        <th>标题</th>
                        <th style="width:35%;">描述</th>
                        <th>发布时间</th>
                        <th class="text-right">操作</th>
                    </tr>
                    </thead>
                    <tbody class="no-border-x no-border-y">
                    <?php if(!empty($list['items'])):
                        foreach ($list['items'] as $key => $value):?>
                        <tr>
                            <td><?php echo $value['id']?></td>
                            <td><?php echo $value['title']?></td>

                            <td style="width:35%;"><?php echo $value['desc']?></td>
                            <td class="text-left"><?php echo date("Y-m-d",$value['last_change'])?></td>
                            <td class="text-right">
                                <a class="btn btn-primary btn-xs" href="<?php echo \yii\helpers\Url::to(['admin/article/add','id' => $value['id']])?>"
                                   data-original-title="编辑" data-toggle="tooltip">
                                    <i class="fa fa-pencil"></i>
                                </a>
                                <a class="btn btn-danger btn-xs" onclick="operateObj.del('<?= $value['id']?>')" data-original-title="删除"
                                   data-toggle="tooltip">
                                    <i class="fa fa-times"></i>
                                </a>
                            </td>
                        </tr>
                    <?php endforeach;endif;?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

<div class="row">
    <div class="col-sm-12">
        <div class="pull-left">
<!--            --><?php //var_dump($list['pages']);?>
            <div class="dataTables_info" id="datatable-icons_info">当前显示第 <?=$list['pages']->offset+1?> - <?=$list['pages']->offset + $list['pages']->limit?> 总计
                <?=$list['pages']->totalCount?>
                条记录</div></div>
        <div class="pull-right">
            <div class="dataTables_paginate paging_bs_normal">

                <?=\yii\widgets\LinkPager::widget([
                    'pagination' => $list['pages'],
                    'prevPageLabel' => '上一页',
                    'nextPageLabel' => '下一页',
                    'firstPageLabel' => '首页',
                    'lastPageLabel' => '末页',
                ]);?>
            </div>
        </div>
        <div class="clearfix"></div>
    </div>
</div>

<?php $this->beginBlock('footerJsText')?>
<script>
    var operateObj = {
        del:function (id) {
            var data= {id :id};
            ajaxLock = false;
            if (ajaxLock)return false;
            ajaxLock = true;
            $.ajax({
                type:'POST',
                dataType:'json',
                data:data,
                url:'<?php echo \yii\helpers\Url::to(['admin/category/delete'])?>',
                success:function (resp) {
                    layer.msg(resp.m);
                },
                error:function () {
                    console.log("save失败");
                }
            });
        }
    };
</script>
<?php $this->endBlock()?>